<?php

use think\Db;
use think\migration\Migrator;
use think\migration\db\Column;

class CreateConfigData extends Migrator
{
    public function up()
    {
        $place = serializeByArray([
            'lat'=> 39.916527,
            'lng'=> 116.397128,
            'address'=> '故宫',
        ]);
        $data = [
            [
                'name' => 'company_logo',
                'title' => '公司LOGO',
                'type' => 'picture',
                'create_time' => time(),
            ],[
                'name' => 'company_number',
                'title' => '公司公众号',
                'type' => 'picture',
                'create_time' => time(),
            ],[
                'name' => 'union_logo',
                'title' => '联盟LOGO',
                'type' => 'picture',
                'create_time' => time(),
            ],[
                'name' => 'union_number',
                'title' => '联盟公众号',
                'type' => 'picture',
                'create_time' => time(),
            ],[
                'name' => 'org_name',
                'title' => '机构名称',
                'type' => 'text',
                'create_time' => time(),
            ],[
                'name' => 'org_phone',
                'title' => '官方电话',
                'type' => 'text',
                'create_time' => time(),
            ],[
                'name' => 'fax',
                'title' => '传真',
                'type' => 'text',
                'create_time' => time(),
            ],[
                'name' => 'email',
                'title' => '邮箱',
                'type' => 'text',
                'create_time' => time(),
            ],[
                'name' => 'postal_code',
                'title' => '邮编',
                'type' => 'number',
                'create_time' => time(),
            ],[
                'name' => 'place_position',
                'title' => '定位',
                'type' => 'json',
                'value' => $place,
                'create_time' => time(),
            ],[
                'name' => 'ICP_number',
                'title' => 'ICP备案编号',
                'type' => 'text',
                'create_time' => time(),
            ],[
                'name' => 'ICP_link',
                'title' => 'ICP备案链接',
                'type' => 'text',
                'create_time' => time(),
            ]
        ];
        foreach ( $data as $item){
            Db::name('config')->insert($item);
        }

    }
    public function down()
    {
        Db::name('config')->where('id', '>', 0)->delete();
    }
}
